package ru.braim.weather_app.models;

import jakarta.persistence.*;
import lombok.Getter;

import javax.print.attribute.standard.MediaSize;
import java.util.List;

@Entity
@Getter
public class RegionType {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column(nullable = false, unique = true)
    private String type;

    @ManyToMany
    @JoinTable(name="regions_and_regions_types",
                joinColumns = @JoinColumn(name = "region_id"),
                inverseJoinColumns = @JoinColumn(name = "region_type_id"))
    private List<Region> regions;

    public boolean setType(String type) {
        if (type == null) {
            return false;
        }
        if (type.isEmpty() || type.isBlank()) {
            return false;
        }
        this.type = type;
        return true;
    }
}
